package com.lwc.cfdns.pojo.bo.system;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.lwc.cfdns.pojo.bo.AbstractPageQuery;
import com.lwc.cfdns.pojo.entity.SystemCate;
import com.lwc.cfdns.utils.StringUtils;
import lombok.Data;

/**
 * 通用分类搜索
 *
 * @author luwc
 * @title CateBO
 * @description
 * @time 2023/5/30 22:45
 * @version: 1.0
 */
@Data
public class CateBO extends AbstractPageQuery<SystemCate> {
    private String type;
    private String name;
    private String status;
    private Long pid;

    @Override
    public LambdaQueryWrapper<SystemCate> toQueryWrapper() {
        LambdaQueryWrapper<SystemCate> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        if (StringUtils.isNotEmpty(type)) {
            lambdaQueryWrapper.eq(SystemCate::getType, type);
        }
        if (StringUtils.isNotNull(pid)) {
            lambdaQueryWrapper.eq(SystemCate::getPid, pid);
        }
        if (StringUtils.isNotEmpty(name)) {
            lambdaQueryWrapper.like(SystemCate::getName, name);
        }
        if (StringUtils.isNotEmpty(status)) {
            lambdaQueryWrapper.eq(SystemCate::getStatus, status);
        }
        return lambdaQueryWrapper;
    }
}
